package com.ruoyi.system.adapter;


import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.domain.AssessTable;
import com.ruoyi.system.domain.dto.AssessTableDTO;
import org.apache.commons.collections4.MapUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

public class AssessTableAdapter {
    public static List<AssessTable> adapter(Map<String, AssessTableDTO> assessTableMap) {
        if (MapUtils.isEmpty(assessTableMap)) {
            return null;
        }
        List<AssessTable> assessTables = new ArrayList<>();

        for (Map.Entry<String, AssessTableDTO> entry : assessTableMap.entrySet()) {
            AssessTableDTO assessTableDo = entry.getValue();
            AssessTable assessTable = new AssessTable();
            if (assessTableDo == null) {
                continue;
            }
            assessTable.setNumber(assessTableDo.getNumber());
            assessTable.setPointsType(assessTableDo.getPointsType());
            assessTable.setEvaluation(assessTableDo.getEvaluation());
            assessTable.setShortName(assessTableDo.getShortName());
            assessTable.setName(assessTableDo.getName());
            assessTable.setIntroduce(assessTableDo.getIntroduce());
            assessTable.setTableCreator(assessTableDo.getTableCreator());
            assessTable.setTaskLevelIds(JSON.toJSONString(assessTableDo.getTaskLevel()));
            assessTable.setQuestionIds(JSON.toJSONString(assessTableDo.getQuestions()));
            assessTable.setRoleId(assessTableDo.getRoleId());
            assessTable.setAdminType(assessTableDo.getAdminType());
            assessTables.add(assessTable);
        }

        return assessTables;
    }
}
